using Todos.Application.Users.Specs;

namespace Todos.Application.Users.Commands;

public class DeleteUserCommand : IRequest<ApiResult>, ICommand
{
    public required long[] Ids { get; set; }
}

public class DeleteUserCommandHandler(IRepository<User> repository)
    : IRequestHandler<DeleteUserCommand, ApiResult>
{
    public async Task<ApiResult> Handle(DeleteUserCommand request, CancellationToken cancellationToken)
    {
        var spec = new UserByIdsSpec(request.Ids);
        await repository.DeleteBatchAsync(spec, cancellationToken);
        return ApiResult.Success();
    }
}